﻿using System;
using System.Collections.Generic;
using System.Text;
using TarreOA.TarreOAModels;
using System.Data.SqlClient;
using System.Data;

namespace TarreOA.TarreOADAL
{
    public class SectionMsgtbDAO
    {
        //将消息记录存入数据库中
        public int saveSectionMsgRecord(string msgContent, int sendUserId, DateTime sendDate)
        {
            int count = 0;
            SqlConnection conn = null;
            try
            {
                conn = SQLManager.GetConn();
                conn.Open();
                string sql = "insert into SectionMsgtb values(@suid,@msg,@sDate)";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.Add(new SqlParameter("@suid", sendUserId));
                cmd.Parameters.Add(new SqlParameter("@msg", msgContent));
                cmd.Parameters.Add(new SqlParameter("@sDate", sendDate));
                count = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return count;
        }
    }
}
